#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
int main()
{
	int* p = (int*)malloc(10 * sizeof(int));
	if (p == NULL)
	{
		perror("malloc");
		return 1;
	}
	int* c = (int*)calloc(10, sizeof(int));
	if (c == NULL)
	{
		perror("calloc");
		return 2;
	}
	c[0] = 0;
	for (int i = 0; i < 10; i++)
	{
		p[i] = i;
		if (i >= 1)
			c[i] = c[i - 1] + p[i];
		printf("%d ", c[i]);
	}
	printf("\n");
	int* prt;
	prt = realloc(c, 20 * sizeof(int));
	if (prt == NULL)
	{
		perror("realloc");
		return 3;
	}
	else
	{
		c = prt;
		prt = NULL;
	}
	for (int i = 10; i < 20; i++)
	{
		c[i] = i;
		printf("%d ", c[i]);
	}
	free(p);
	p = NULL;
	free(c);
	c = NULL;

	return 0;
}